package com.mr.cai.main.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.mr.cai.main.R;
import com.mr.cai.main.activity.base.MrCaiBaseActivity;
import com.mr.cai.main.utils.CommonCoreUtil;

import rx.functions.Action1;

/**
 * Created by hai8108 on 16/2/25.
 */
public class MrCaiSafeCenterActivity extends MrCaiBaseActivity {
    private final static int MRCAI_SAFE_CENTER = 4;
    private View[] mrCaiSafeItemViews = new View[MRCAI_SAFE_CENTER];
    private TextView[] mrCaiTextViews = new TextView[MRCAI_SAFE_CENTER];
    private TextView[] mrCaiTextSubViews = new TextView[MRCAI_SAFE_CENTER];
    private TextView[] mrCaiTextRightViews = new TextView[MRCAI_SAFE_CENTER];

    private int[] safeStrId = {R.string.mr_cai_safe_login_pwd_txt, R.string.mr_cai_safe_email_txt,
                                R.string.mr_cai_safe_change_modile_num_txt,R.string.mr_cai_safe_pay_pwd_txt};

    private int[] safeSubStrId = {R.string.mr_cai_safe_login_pwd_tag_txt, R.string
            .mr_cai_safe_email_tag_txt,
            R.string.mr_cai_safe_change_modile_num_tag_txt,R.string.mr_cai_safe_pay_pwd_tag_txt};

    private int[] safeRightStrId = {R.string.mr_cai_safe_change_txt, R.string
            .mr_cai_safe_bind_txt,
            R.string.mr_cai_safe_change_number_txt,R.string.mr_cai_safe_set_txt};
    public static void launch (Activity activity) {
        Intent intent = new Intent(activity, MrCaiSafeCenterActivity.class);
        activity.startActivity(intent);
    }

    @Override
    public void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting_safe_center_layout);
        findView();
        initData();
    }

    private void findView () {
        CommonCoreUtil.setClickAction(findViewById(R.id.top_view).findViewById(R.id.pub_top_left)
                , new Action1() {
            @Override
            public void call (Object o) {
                finish();
            }
        });
        ((TextView) findViewById(R.id.top_view).findViewById(R.id.pub_top_mid)).setText(R.string.my_setting_safe_txt);
    }

    private void initData () {
        mrCaiSafeItemViews[0] = findViewById(R.id.mr_cai_safe_center_login_pwd);
        mrCaiSafeItemViews[1] = findViewById(R.id.mr_cai_safe_center_email_check);
        mrCaiSafeItemViews[2] = findViewById(R.id.mr_cai_safe_center_change_mobile);
        mrCaiSafeItemViews[3] = findViewById(R.id.mr_cai_safe_center_reset_pwd);
        for (int i = 0; i < MRCAI_SAFE_CENTER; i++) {
            mrCaiTextViews[i] = (TextView) mrCaiSafeItemViews[i].findViewById(R.id.mr_cai_safe_left_top_txt);
            mrCaiTextSubViews[i] = (TextView) mrCaiSafeItemViews[i].findViewById(R.id
                    .mr_cai_safe_left_bottom_txt);
            mrCaiTextRightViews[i] = (TextView) mrCaiSafeItemViews[i].findViewById(R.id
                    .mr_cai_safe_right_txt);

            mrCaiTextViews[i].setText(safeStrId[i]);
            mrCaiTextSubViews[i].setText(safeSubStrId[i]);
            mrCaiTextRightViews[i].setText(safeRightStrId[i]);

        }
    }
}
